<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCompanyMaterialTask extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_material_task', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedBigInteger('region_id')->comment('所属城市');
            $table->string('path')->comment('文件地址');
            $table->unsignedBigInteger('count')->default(0)->comment('文件总数');
            $table->unsignedBigInteger('limit_sum')->default(0)->comment('每次发布数量');
            $table->string('time')->comment('发布时间');
            $table->unsignedBigInteger('released')->default(0)->comment('已发布数量');
            $table->timestamps();
        });

        Schema::create('company_material', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('task_id')->comment('任务id');
            $table->string('name', 150)->comment('公司名称');
            $table->unsignedInteger('media_id')->nullable()->comment('公司logo');
            $table->unsignedInteger('region_id')->comment('所属城市');
            $table->string('type')->nullable()->comment('企业类型');
            $table->text('business_scope')->nullable()->comment('经营范围');
            $table->string('location')->nullable()->comment('地址');
            $table->string('credit_code')->nullable()->comment('信用代码');
            $table->string('legal_person')->nullable()->comment('法人');
            $table->string('established_at', 30)->nullable()->comment('成立时间');
            $table->string('capital', 30)->nullable()->comment('注册资本');
            $table->string('email')->nullable()->comment('邮箱');
            $table->string('tel')->nullable()->comment('电话');
            $table->string('more_tel')->nullable()->comment('电话');
            $table->string('website')->nullable()->comment('网址');
            $table->boolean('is_state')->default(false)->comment('发布状态');
            $table->timestamps();
            $table->index(['task_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('company_material_task');
        Schema::dropIfExists('company_material');
    }
}
